package com.mechat.dialog

import android.Manifest
import android.app.Activity
import android.os.Build
import android.view.animation.AnimationUtils
import android.widget.ImageView
import android.widget.TextView
import com.mechat.R
import com.mechat.util.HttpRequest
import com.mechat.util.PermissionUtils
import com.custom.base.config.BaseConfig
import io.rong.imkit.SpName
import razerdp.basepopup.BasePopupWindow

/**
 * 权限请求
 */
class NotificationPermissionDialog(var ctx: Activity, var listener:OnListener) :  BasePopupWindow(ctx) {
    init {
        setContentView(R.layout.dialog_notification_permission)
        initView()
    }

    private fun initView() {
        val dialogConfirm = findViewById<TextView>(R.id.dialog_got_it)

        dialogConfirm.setOnClickListener {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
                PermissionUtils.requestPermission(ctx,
                    {
                        listener.onGrantedListener()

                    }, {
                        listener.onDeniedListener()
                    },Manifest.permission.POST_NOTIFICATIONS)
            }
            dismiss()
        }
        setOutSideDismiss(true)
    }

    interface OnListener{
        fun onGrantedListener()
        fun onDeniedListener()
    }
}